<?php

namespace App\Http\Controllers\Common;


use App\Models\Company;
use App\Models\Project;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

/**
 * 通知短息逻辑控制器
 *
 * Date: 10/04/2018
 * @author George
 * @package App\Http\Controllers\Common
 */
class ConditionController extends Controller
{
    /**
     * 获取除本公司外的其他公司
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
	public function getCompany(Request $request)
	{
        $company = $request->user()->company_id;
        $companies = Company::query()->where('status','accepted')->get()->whereNotIn('id',$company)->all();
        return success($companies);
	}

    /**
     * 根据公司信息获取项目信息
	 *
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
	public function getProject(Request $request)
    {
        $company = $request->get('company');
        if($company){
            $project = Project::query()->where('company_id',$company)->get();
        }else{
            $project = Project::query()->get();
        }

        return success($project);
    }
}
